package com.example.mapper;

import com.example.dto.ComplaintDto;
import com.example.dto.OrderSearchDto;
import com.example.entity.OrderComplaint;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 朽
* @description 针对表【order_complaint(订单投诉)】的数据库操作Mapper
* @createDate 2024-06-08 21:25:59
* @Entity com.example.entity.OrderComplaint
*/
public interface OrderComplaintMapper extends BaseMapper<OrderComplaint> {

    @Select("select * from order_complaint")
    List<OrderComplaint> getAll();

    @Select({"<script>",
            "SELECT o.order_sn AS orderSn, o.user_name AS userName, oc.*",
            "FROM `order` o",
            "LEFT JOIN order_complaint oc ON o.id = oc.order_id",
            "<where>",
            "<if test='orderNo != null and orderNo.trim() != \"\"'>",
            "AND o.order_sn LIKE CONCAT('%', #{orderNo}, '%')",
            "</if>",
            "<if test='memberName != null and memberName.trim() != \"\"'>",
            "AND o.user_name LIKE CONCAT('%', #{memberName}, '%')",
            "</if>",
            "<if test='status != null'>",
            "AND oc.status = #{status}",
            "</if>",
            "</where>",
            "</script>"})
    List<ComplaintDto> getsearchComplaint(OrderSearchDto orderSearchDto);

    @Select("select * from order_complaint WHERE id = #{id}")
    OrderComplaint selectComplaintDetailById(Long id);
}




